﻿
@{
    Layout = "~/Views/Shared/_MyLayout.cshtml";
}
@using Model;
@using PagedList.Mvc;
@model PagedList.IPagedList<userView>
@*@model PagedList.IPagedList<Users>*@

<div class="header">

    <h1 class="page-title">用户管理</h1>
</div>

<ul class="breadcrumb">
    <li><a href="admin/index">首页</a> <span class="divider">/</span></li>
    <li class="active">用户列表</li>
</ul>

<div class="container-fluid">
    <div class="row-fluid">

        <div class="btn-toolbar">
            <button class="btn btn-primary"><i class="icon-plus"></i><a href="/User/AddUser">新增用户</a></button>
            <button class="btn">导入</button>
            <button class="btn">导出</button>           
            <div class="btn-group">
            </div>
        </div>
        <div class="well">
            <table class="table">
                <thead>
                    <tr>
                        <th>用户名</th>
                        <th>真实姓名</th>
                        <th>角色</th>
                        <th>创建日期</th>
                        <th style="width: 26px;"></th>
                    </tr>
                </thead>
                <tbody>
                    @if (Model != null && Model.Any())
                    {
                        foreach (var item in Model)
                        {
                            <tr>
                                <td>@item.username </td>
                                <td>@item.truename </td>
                                <td>@item.rolename </td>       
                                <td>@item.createdate </td>
                                <td>
                                    <a href="/user/edit/@item.id"><i class="icon-pencil"></i></a>
                                    <a href="#myModal" role="button" onclick="Del(@item.id)" data-toggle="modal"><i class="icon-remove"></i></a>
                                </td>
                            </tr>

                        }
                        
                    }
                </tbody>
                
            </table>
            
        </div>
                <div class="pagination">
            @Html.PagedListPager(Model, page => Url.Action("Index", new { page }))
        </div>
        @Html.ActionLink("点击导出Excel", "ExportStu2")
            <footer>
                <hr>

                <p class="pull-right">Collect from <a href="http://www.cssmoban.com/" title="网页模板" target="_blank">网页模板</a></p>


                <p>© 2016 <a href="#" target="_blank">Portnine</a></p>
            </footer>

        </div>
</div>
<script type="text/javascript">
    //删除用户
    function Del(id) {
        $.ajax({
            type: "POST",
            url: "User/DelUser",
            data: { id: id },
            success: function (data) {
                if (data.success) {
                    alert(data.msg);
                    window.location = location;
                }
                else {
                    alert(data.msg);
                }
            }
        });
        
    }
</script>
